<?php
class Admin_Form_AddHotel extends Admin_Form_AddArticle {
	public function init() {
		$dataMaper 	= new M_Tool_DataMapper();
		$rating		= array(0 => 'None',
							1 => '1 star',
							2 => '2 star',
							3 => '3 star',
							4 => '4 star',
							5 => '5 star',
							6 => '6 star',
							7 => '7 star');

		$title 	 = new Zend_Form_Element_Text('title');
		$enTitle = new Zend_Form_Element_Text('en_title');

		$name = new Zend_Form_Element_Text(
				'name',
				array('label'	=> 'Hotel name (Vi)',
						'filters'		=> array('StringTrim')));

		$enName = new Zend_Form_Element_Text(
				'en_name',
				array('label'	=> 'Hotel name (En)',
					  'required'	 => true,
						'filters'		=> array('StringTrim')));

		$tbHotelType  = new M_DbTable_HotelType();
		$hotelType 	  = new Zend_Form_Element_Select(
				'hotel_type_id',
				array('label'		 => 'Hotel type',
					  'required'	 => true,
					  'multiOptions' => $dataMaper->mapKeyValue($tbHotelType->getList(),'id', 'en_title')));

		$bestSelling 	  = new Zend_Form_Element_Select(
				'best_selling',
				array('label'		 => 'Best selling',
					  'multiOptions' => array(1 => 'Yes', 0 => 'No')));

		$specialOffer 	  = new Zend_Form_Element_Select(
				'special_offer',
				array('label'		 => 'Promotion',
					  'multiOptions' => array(1 => 'Yes', 0 => 'No')));

		$tbcountry = new M_DbTable_Country();
		$country   = new Zend_Form_Element_Select(
				'country_id',
                 array('label'        => 'Country',
                 	   'required'	 => true,
                 	   'RegisterInArrayValidator' => false,
                       'attribs'      => array('class'                     => 'chainselect input-medium',
						                       'data-chainselect-source'   => '/admin/index/ajax?ajax=list-region',
						                       'data-chainselect-target'   => '[data-chainselect-selector=\'region-1\']'),
						                       'multiOptions' => $dataMaper->mapKeyValue(
							                       new M_DbTable_Country(),
							                       'id',
							                       'en_name',
							                       array('' => 'Country')
						                       )
                 		));

		$tbRegion = new M_DbTable_Region();
		$region   = new Zend_Form_Element_Select(
				'region_id',
				array(
						'label'    => 'City - province',
                 	    'required'	 => true,
						'RegisterInArrayValidator' => false,
						'attribs'  => array(
								'class'	                    => 'input-medium',
								'data-chainselect-selector' => 'region-1',
						),
						'multiOptions' => ($this->_request->getActionName() == 'edit')
										  ? $dataMaper->mapKeyValue(
							                       new M_DbTable_Region(),
							                       'id',
							                       'en_name')
										  : array('' => 'City - province')
				)
		);

		$rate = new Zend_Form_Element_Select(
				'rating',
				array('label' 		=> 'Ratting star',
					  'cols'		=> 100,
					  'multiOptions' => $rating));

		$phone = new Zend_Form_Element_Text(
				'phone',
				array('label' 		=> 'Phone',
					  'cols'		=> 100));

		$hotline = new Zend_Form_Element_Text(
				'hotline',
				array('label' 		=> 'HotLine',
					  'cols'		=> 100));

		$fax = new Zend_Form_Element_Text(
				'fax',
				array('label' 		=> 'Fax',
					  'cols'		=> 100));

		$email = new Zend_Form_Element_Text(
				'email',
				array('label' 		=> 'Email',
					  'cols'		=> 100));
		$address = new Zend_Form_Element_Text(
				'address',
				array('label' 		=> 'Address (Vi)',
					  'cols'		=> 100,
					  'class'		=> 'input-xxlarger'));

		$enAddress = new Zend_Form_Element_Text(
				'en_address',
				array('label' 		=> 'Address (En)',
					  'cols'		=> 100,
					  'class'		=> 'input-xxlarger'));

		$description = new Zend_Form_Element_Textarea(
				'description',
				array('label' 		=> 'Description'));

		$thumbnail = new Zend_Form_Element_File(
				'thumbnail',
				array('label' => 'Photo (display in article)'));

		$avatar = new Zend_Form_Element_File(
				'avatar',
				array('label' => 'Avatar'));

		$metaKeyWord = new Zend_Form_Element_Textarea(
		        'meta_keyword',
		        array('label' 		=> 'Meta keywords',
					  'rows'	=> 5,
					  'cols'	=> 80));

		$metaDescription = new Zend_Form_Element_Textarea(
		        'meta_description',
		        array('label' 		=> 'Meta description',
					  'rows'	=> 5,
					  'cols'	=> 80));
		$headerTitle = new Zend_Form_Element_Textarea(
		        'header_title',
		        array('label' 		=> 'Header title',
					  'rows'	=> 5,
					  'cols'	=> 80));

		$this->addElement($name)
			 ->addElement($enName)
			 ->addElement($hotelType)
			 ->addElement($bestSelling)
			 ->addElement($specialOffer)
			 ->addElement($country)
			 ->addElement($region)
			 ->addElement($rate)
			 ->addElement($phone)
			 ->addElement($hotline)
			 ->addElement($fax)
			 ->addElement($email)
			 ->addElement($address)
			 ->addElement($enAddress)
			 ->addElement($title)
			 ->addElement($enTitle)
			 ->addElement($metaKeyWord)
			 ->addElement($metaDescription)
			 ->addElement($headerTitle)
			 ->addElement($avatar)
			 ->addElement($thumbnail);

		parent::init();

		$this->setLegend('Add new Hotel & Resort');
		$this->addActionGroup()
			 ->makeup();
	}
}